home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / VideoToolboxSources / CenterRectInRect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  890 b   |  34 lines  |  [TEXT/MMCC]

  1. /*
  2. CenterRectInRect.c
  3. ©1991-1994 Denis G. Pelli
  4. These routines are trivial, but enhance the readability of programs that use them.
  5.  
  6. HISTORY:
  7. 8/24/91    dgp    Made compatible with THINK C 5.0.
  8. 1/25/93 dgp removed obsolete support for THINK C 4.
  9. 11/22/94 dgp renamed "RectInRect" to IsRectInRect().
  10. */
  11. #include "VideoToolbox.h"
  12.  
  13. void CenterRectInRect(Rect *a,Rect *b)
  14. {
  15.     OffsetRect(a,(b->left + b->right - a->left - a->right)/2
  16.         ,(b->top + b->bottom - a->top - a->bottom)/2);
  17. }
  18.  
  19. void OffsetRectTile(Rect *r,int nx,int ny) /* shift rect by multiples of the rect */
  20. // Shift rect by multiples of the rect
  21. {
  22.     OffsetRect(r,nx*(r->right-r->left),ny*(r->bottom-r->top));
  23. }
  24.  
  25. Boolean IsRectInRect(Rect *r,Rect *R)
  26. // Is the first rect entirely inside the second?
  27. // If either rect has zero area then this routine will return false.
  28. {
  29.     Rect t;
  30.     
  31.     if(!SectRect(r,R,&t))return 0;
  32.     return EqualRect(r,&t);
  33. }
  34.